class Solution {
    public int[] singleNumbers(int[] nums) {
        //假设两数为a,b
        int[] single = new int[2];
        for(int x:nums) {
            single[0] ^= x;
        }
        //此时single[0]的结果为a^b,一定不为0
        //提取single[0]最右侧的1,并且依此标准将数组元素进行分类
        int rightOne = single[0] & (~single[0] + 1);
        for(int x:nums) {
            if ((rightOne & x) == 0) single[1] ^= x;
        }
        single[0] = single[1] ^ single[0];
        return single;
    }
}